#include "Random.h"

Random::Random()
{
	SetSeed();
}

Random::~Random()
{
	// Empty
}

void Random::SetSeed()
{
	mSeed = (u32)(std::time(NULL));
	std::srand(mSeed);
}

void Random::SetSeed(u32 seed)
{
	mSeed = seed;
	std::srand(mSeed);
}

u32 Random::GetSeed() const
{
	return mSeed;
}

bool Random::Bool() const
{
	return (std::rand() % 2) == 0;
}

s32 Random::Int(s32 min, s32 max) const
{
	if(max <= min) return min;

	return min + std::rand() % (max - min + 1);
}

f32 Random::Float(f32 min, f32 max) const
{
	if(max <= min) return min;

	return min + (max - min) * ((f32)(std::rand()) / (f32)(RAND_MAX + 1));
}

c8 Random::Digit() const
{
	return (c8)(Int('0', '9'));
}

c8 Random::Letter() const
{
	return Bool() ? UpperCaseLetter() : LowerCaseLetter();
}

c8 Random::LowerCaseLetter() const
{
	return (c8)(Int('a', 'z'));
}

c8 Random::UpperCaseLetter() const
{
	return (c8)(Int('A', 'Z'));
}
